var ajax = require('../../utils/ajax.js');
var app = getApp();
var scope;
var self;
var shop = {};

function init(thisScope, that) {
  scope = thisScope;
  self = that;
  shop = app.getShop();

  that.setData({
    [`${scope}`]: { shop }
  });

  that['_callPhone'] = callPhone;
  that['_toMap'] = toMap;
}

/**
  * 调用电话接口
  */
function callPhone() {
  wx.makePhoneCall({
    phoneNumber: shop.phone,
  })
}

/**
 * 跳转至地图
 */
// function toMap() {
//   ajax.G('/openapi/CAddress/getLocation', {
//     addr: shop.address
//   }, function (data) {
//     var addressInfo = JSON.parse(data.result)['result'];

//     wx.openLocation({
//       latitude: addressInfo.location.lat,
//       longitude: addressInfo.location.lng,
//       name: shop.name,
//       address: shop.address,
//     })
//   });
// }

module.exports = {
  init: init
};

